﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using CloudClass.Models;
using Orchard.Data;

namespace CloudClass.Services
{
    public class CourseClassifyService : ICourseClassifyService
    {
        private readonly IRepository<CourseClassify> _courseClassifyRepository;
        //private readonly IEnumerable<ICarEventHandler> _handlers; 
        public CourseClassifyService(IRepository<CourseClassify> courseClassifyRepository)
        {
            _courseClassifyRepository = courseClassifyRepository;
            //_handlers = handlers;
        }

        public virtual bool Create(Models.CourseClassify model)
        {

            try
            {
                _courseClassifyRepository.Create(model);
            }
            catch
            {
                return false;
            }
            return true;
        }

        public virtual bool Edit(CourseClassify model)
        {
            try
            {
                _courseClassifyRepository.Update(model);
            }
            catch
            {
                return false;
            }
            return true;
        }

        public virtual bool Delete(int[] array)
        {
            try
            {
                foreach (var id in array)
                {
                    var item = this.Get(id);
                    _courseClassifyRepository.Delete(item);
                }
            }
            catch
            {
                return false;
            }
            return true;
        }

        public virtual CourseClassify Get(int id)
        {
            var item = _courseClassifyRepository.Get(id);
            return item;
        }

        public virtual List<CourseClassify> GetList()
        {
            return _courseClassifyRepository.Table.ToList();
        }

    }
}